package com.wenx.v3auth.config;

import com.wenx.v3auth.interceptor.V3TokenEndpointInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Auth服务 Web MVC 配置
 * 
 * @author wenx
 * @since 1.0.0
 */
@Configuration
@RequiredArgsConstructor
public class AuthWebMvcConfig implements WebMvcConfigurer {

    private final V3TokenEndpointInterceptor endpointInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // OAuth2 Token端点拦截器 - 专门处理OAuth2相关请求
        registry.addInterceptor(endpointInterceptor)
                .addPathPatterns("/oauth2/**", "/connect/**", "/userinfo")
                .order(1); // 设置执行顺序，数字越小优先级越高

    }
}
